package ch.zbw.rre.queue;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class TestQueueJUnit {


	private Queue myQueue;
	
	
	public TestQueueJUnit()
	{
		super();
		
	}

	@Before
	public void setUp()
	{
		myQueue = new QueueArray();
//		myQueue = new QueueVerketteteListe();
	}
	
@Test
	public void testEmpty()
	{
		assertEquals(true, myQueue.empty());	
		assertEquals(null, myQueue.deq());
		myQueue.enq(new Element(33,"Genf"));
		assertEquals(false, myQueue.empty());	
	}

@Test
	public void testEnq()
	{
		assertEquals(true, myQueue.enq(new Element(2,"Basel")));	
		assertEquals(true, myQueue.enq(new Element(4,"Wil")));	
		assertEquals(true, myQueue.enq(new Element(27,"Chur")));	
		assertEquals(true, myQueue.enq(new Element(007,"London")));	
		assertEquals(false, myQueue.enq(new Element(99,"Wattwil")));
		assertEquals(2, myQueue.deq().getId());	
		assertEquals(4, myQueue.deq().getId());	
		assertEquals(true, myQueue.enq(new Element(006,"St.Gallen")));	
		assertEquals(27, myQueue.deq().getId());		
		assertEquals("London", myQueue.deq().getName());	
	}

@Test
	public void testDeq()
	{
		// lesen im leeren Stack
		assertEquals(null,myQueue.deq());
	
		assertEquals(true, myQueue.enq(new Element(2,"Basel")));	
		assertEquals(true, myQueue.enq(new Element(4,"Wil")));	
		assertEquals(true, myQueue.enq(new Element(27,"Chur")));
		assertEquals(2,myQueue.deq().getId());
		assertEquals("Wil",myQueue.deq().getName());
		assertEquals(27,myQueue.deq().getId());
		
		// leerer Stack
		assertEquals(null,myQueue.deq());
	
	}


		
}


